package hiho.ku._1040;

import java.util.Scanner;

public class Main {

	private static final int[] x = new int[8];
	private static final int[] y = new int[8];
	private static final int[] c = new int[8];

	private static final int[] dx = new int[4];
	private static final int[] dy = new int[4];

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		for (int i = 0; i < t; i++)
			run(in);
	}

	private static void run(Scanner in) {
		for (int i = 0; i < 8; i++) {
			x[i] = in.nextInt();
			y[i] = in.nextInt();
			c[i] = 0;
		}
		for (int i = 0; i < 8; i++)
			for (int j = 0; j < 8; j++)
				if (x[i] == x[j] && y[i] == y[j])
					c[i]++;
		for (int i = 0; i < 8; i++)
			if (c[i] != 2)
				System.out.println("NO");

		for (int i = 0; i < 4; i++) {
			dx[i] = x[i * 2] - x[i * 2 + 1];
			dy[i] = y[i * 2] - y[i * 2 + 1];
		}
		int px = 0;
		int cz = 0;
		for (int i = 1; i < 4; i++)
			if (dx[0] * dy[i] - dy[0] * dx[i] == 0)
				px++;
			else if (dx[0] * dx[i] + dy[0] * dy[i] == 0)
				cz++;
		if (px == 1 && cz == 2)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}
